package com.jinlia.show.modules.wxapp.controller;

import com.jinlia.show.common.core.utils.UserInfoUtils;
import com.jinlia.show.modules.base.model.po.UserCouponRelPO;
import com.jinlia.show.modules.base.model.query.UserCouponQuery;
import com.jinlia.show.modules.base.wxapp.entity.UserCouponRel;
import com.jinlia.show.modules.base.wxapp.service.UserCouponRelMapperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 *用户优惠券
 */
@RestController
@RequestMapping("/userCouponRel")
public class UserCouponRelController {

    @Autowired
    UserCouponRelMapperService userCouponRelMapperService;

    /**
     * 获取列表
     */
    @PostMapping("/list")
    private List<UserCouponRelPO> getList(@RequestBody UserCouponQuery userCouponQuery) {
        userCouponQuery.setUserId(UserInfoUtils.getUserId());
        return userCouponRelMapperService.selectList(userCouponQuery);
    }
    /**
     * 领取优惠券
     */
    @PostMapping("/receive")
    private UserCouponRel receiveCoupon(@RequestBody  UserCouponRel userCouponRel) {
        userCouponRel.setUserId(UserInfoUtils.getUserId());
        return userCouponRelMapperService.receiveCoupon(userCouponRel);
    }
}
